/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sysmo.server.util;

/**
 *
 * @author Derek
 */
public class UtilHelper {
    public static String encodeJSString(String str) {
        return str.replaceAll("[\\\\]", "\\\\\\\\").replaceAll("'", "\\\\\'").replaceAll("[\"]", "\\\\x22").replaceAll("\\n", "\\\\n");
    }

    public static String encodeAutoLineBreak(String str) {
        if (str.indexOf("<br") > 0 || str.indexOf("<p") > 0) {
            return str;
        }
        return str.replaceAll("\n", "<br />");
    }
}
